<?php

namespace Common\Service;


/** 
 * 视频标签
 * @author Legend. <xcx_legender@qq.com>
 * @param 
 * @return 
 */

Class VideoTagService extends BaseService
{
	/**
	video_id,  tag (varchar)



	 */
	protected $pk           = '_id';
	public function addTag($video_id, $tag)
	{
		static $video_tags;

		// $video_id = $video['id'];
		if (!$video_tags[$video_id])
		{
			$map['video_id'] = $video_id;
			$tags = $this->where($map)->field('title')->select();
			if ($tags)
			{
				foreach ($tags as $key => $value) {
					$video_tags[$video_id][] = $value['title'];
				}
			}
		}
		if (!in_array($tag, $video_tags[$video_id]))
		{
			$data['video_id'] 		= $video_id;
			$data['tag']      		= $tag;
			$data['create_time'] 	= NOW_TIME;
			$this->add($data);
			$video_tags[$video_id][] = $tag;
		}
	}
	


}